import type * as Common from './common/type'
import type { Student } from './student'
import http from '@/utils/http'

export interface ArragngeTemplateName {
  id: string
  name: string
  lessonCount: number
  startDate: string
  endDate: string
}

export interface TimeTemplateName {
  id: string
  name: string
  startTime: string
  endTime: string
}

export interface ClassInfo {
  id: string
  name: string
  classYear: number
  admissionYearLimit: number
  term: string
  grade: string
  subject: string
  classCategory: number
  classTypeId: string
  classLevelLimit: number
  campusId: string
  classroomId: string
  leadTeacherId: string
  assistTeacherId: string
  totalLessonCount: number
  completedLessonCount: number
  planStudentCount: number
  enrollStudentCount: number
  passedStudentCount: number
  salePerformanceFactor: number
  lessonHourFactor: number
  arrangeTemplateId: string
  timeTemplateId: string
  lessonChangeLimit: number
  totalPrice: number
  unitPrice: number
  saleStatus: number
  classStatus: number
  renewalStartTime: string
  renewalEndTime: string
  enrollStartTime: string
  image: string
  remainCount: number
}

export interface Enrollment {
  id: string
  studentId: string
  classId: string
  enrollLessonCount: number
  completedLessonCount: number
  cancelLessonCount: number
  remainClassChangeCount: number
  remainLessonChangeCount: number
  renewalClassIds: string[]
  status: string
  sellerId: string
  remark: string
  isRenewal: boolean
}

export interface ClassStudentResp extends Enrollment {
  student: Student
}

/** 班级信息 */
export interface ClassInfoResp extends ClassInfo {
  campusName: string
  classroomName: string

  arrangeTemplate: ArragngeTemplateName
  timeTemplate: TimeTemplateName
}

/** 班级查询请求 */
export interface ClassQuery {
  classYear?: string
  term?: string
  grade?: string
  classStatus?: number[]
}

export interface ClassStudentQuery {
  classId: string
  status?: string
}

export interface TeacherClassStudentResp {

}

export enum StudentStat {
  normal = 'NORMAL',
  canceled = 'CANCELED',
}

export function getClassDetail(classId: string) {
  return http.get<ClassDetailResp>(`/t/class/detail/${classId}`)
}

// 班级列表
export function getClassInfoPage(query: ClassQuery) {
  return http.get<Page<ClassInfoResp>>('/t/class/page', query)
}

// 班级学生名单（新)
export function getClassStudentList(query: ClassStudentQuery) {
  return http.get<ClassStudentResp[]>(`/t/class/student/list`, query)
}
